<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@ include file="common.jsp" %>
<%
SessionUser sessionUser = (SessionUser)LoginContext.getSessionValueByLogin(request);
String url = request.getParameter("url");//打开页面，常用于IM打开链接，定位页面
String mid = request.getParameter("mid");	//跳转项目代码
if(mid == null){
	mid = ConstWords.getProjectCode();
}

int height = ConstWords.getProjectChangeHeight(sessionUser.getUserModuleMethods().size());	//功能切换栏高度

SysConfig sysconfig = sessionUser.getSysconfig();
SysMethodInfo method = UtilTool.getSysMethodInfoByPk(this.getServletContext(),ConstWords.getProjectCode());
String ietitle="";
String titname="";
String titenname="";
if(sysconfig==null || method == null){
	out.print("不能加载配置系统信息..");
	return;
}else{
	ietitle = sysconfig.getProjectName();
	titname = sysconfig.getProjectName();
	titenname = sysconfig.getProjectEgName();
}

SysCompanyInfo company = sessionUser.getCompanyInfo();
if(company!=null){
	if(company.getCompanyInfoTitle()!=null&&company.getCompanyInfoTitle().trim().length()>0){
		ietitle = company.getCompanyInfoTitle();
	}
}

int clogin = -1;
if(company!=null){
	if(company.getCompanyInfoLogin()!=null&&company.getCompanyInfoLogin()>0){
		clogin = company.getCompanyInfoLogin();
	}
	if(company.getCompanyInfoTitle()!=null&&company.getCompanyInfoTitle().trim().length()>0){
		titname = company.getCompanyInfoTitle();
	}
	if(company.getCompanyInfoEnTitle()!=null&&company.getCompanyInfoEnTitle().trim().length()>0){
		titenname = company.getCompanyInfoEnTitle();
	}
}

//跑马灯
WebApplicationContext webcontext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
DwrOADesktopService dekService = (DwrOADesktopService)webcontext.getBean("dwrOADesktopService");
String min = SystemConfig.getParam("erp.desktop.showMinRow");
int rowcount = Integer.parseInt(min);
List<OaNotice> listNotice = dekService.getOaNoticeListByEmpId(this.getServletContext(),request,rowcount);
List<OaAnnouncement> listAnnouncement = dekService.getOaAnnouncementBydesk(this.getServletContext(),request,rowcount);

List<SysMethodInfo> userModuleMethods = sessionUser.getUserModuleMethods();//个人功能模块
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title><%=ietitle %></title>
		<link rel='stylesheet' type='text/css' href='<%=contextPath%>/js/tabs/tabs.css' />
		<script type="text/javascript" src="<%=contextPath%>/js/tabs/tabs.js"></script>
		<script type="text/javascript" src="<%=contextPath %>/dwr/interface/dwrSysProcessService.js"></script>
		<script type="text/javascript">
		window.onload = function(){
			//登陆提示信息
			var msg = "<%=request.getAttribute(ConstWords.TempStringMsg)%>";
			if(msg != "null" && msg.length > 0){
				alert(msg);
			}
			document.getElementById("methodleftfrm").src="<%=request.getContextPath() %>/erp/index_left.jsp?mid=<%=mid%>";
			autoOpen();
			showtime();
		}
		
		function autoOpen(){
			MDIOpen("<%=contextPath %>/erp/center.jsp");
			dwrSysProcessService.listSysMethodAutoOpen(function(data){
				for(var i=0;i<data.resultList.length;i++){
					var url = '<%=contextPath %>/erp/' + data.resultList[i].methodUri;
					autoOpenTmp(url,i);
				}
			});
			
			//打开页面
			var openUrl = "<%= url%>";
			if(openUrl != "null" && openUrl != ""){
				MDIOpen("<%=contextPath %>/erp/"+openUrl);
			}
		}
		function autoOpenTmp(url,i){
			setTimeout(function(){MDIOpen(url);},(i+1)*1500);
		}
		
		function showtime() {
		  var tm = getServerDate();
		  var year = tm[0];
		  var month = tm[1];
		  var date = tm[2];
		  var hours = tm[3];
		  var minutes =tm[4];
		  var seconds =tm[5];
		  var day = tm[6];
		  var tp = tm[7];
		  var timeValue = "";
		  timeValue += year + "年";
		  timeValue += month + "月";
		  timeValue += date + "日  ";
		  timeValue += day + "  ";
		  //timeValue += tp+" ";

		  timeValue += hours;
		  timeValue +=  ":" + minutes;
		  timeValue += ":" + seconds;
		  document.getElementById("systime").innerHTML = timeValue;
		  timerID = setTimeout("showtime()",1000);
		  timerRunning = true;
		}
		</script>
	</head>

	<body>
		
		<table width="100%" cellpadding="0" cellspacing="0" border="0" height="100%">
		<tr>
		<td height="75" style="background:url('<%=request.getContextPath()%>/images/top-5.png') repeat-x;">
		
			<!-- 首页顶部开始 -->
			<table width="100%" cellpadding="0" cellspacing="0" border="0" height="100%">
			<tr>
			<td style="margin-bottom: 10px;padding-left:5px;padding-right:5px">
				<%if(clogin>0){ %>
				<img border="0" alt="公司logo" src="<%=contextPath %>/showimg.do?imgId=<%=clogin %>&noImgPath=<%=com.eazytec.common.util.security.Base64.getBase64FromString(this.getServletContext().getRealPath("/images/syslogin.png"))%>" style="height: 48px;width: auto">
				<%}else{ %>
				<img border="0" alt="公司logo" src="<%=contextPath %>/images/syslogin.png" style="height: 48px;width: auto">
				<%} %>
			</td>
			<td style="margin-bottom: 10px;" align="right" valign="top" width="380">
				<table cellpadding="0" cellspacing="0" border="0" height="98%" width="100%">
					<tr height="50%">
						<td align="left" valign="top">
							<div class="index_title" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;width: 380px;"><%=titname %></div>
						</td>
					</tr>
					<tr>
						<td align="left" valign="top">
							<div class="index_title_en" style="overflow:hidden;	white-space:nowrap;	text-overflow:ellipsis;width: 380px;" title="<%=titenname %>"><%=titenname %></div>
						</td>
					</tr>
				</table>
			</td>
			<td valign="top" style="padding-right: 5px" width="100%" align="right">
				<table cellpadding="0" cellspacing="0" border="0">
					<tr>
					<td align="right" valign="middle" height="21" style="background: url('<%=contextPath%>/images/wpa_left.png')  no-repeat left center;padding-left:10px" >
						<div style="padding-right: 10px;margin-top: 10px; width:300px;">
						<span class="index_msg">欢迎您：<%=sessionUser.getEmployeeName() %></span>&nbsp;&nbsp;
						<span class="index_msg">[ 部门:<%=sessionUser.getEmployeeDeptName() %></span>&nbsp;&nbsp;
						<span class="index_msg">岗位:<%=sessionUser.getMainPost() == null ? "管理员" : sessionUser.getMainPost().getHrmPostName() %> ]</span>
						</div>
					</td>
					<td valign="middle" width="10" height="21" style="background: url('<%=contextPath%>/images/wpa_right.png')  no-repeat right center;">
					</td>
					</tr>
				</table>
			</td>
			</tr>
			<tr>
			<td colspan="3" height="27">
				<table width="100%" cellpadding="0" cellspacing="0" border="0" style="padding-right:5px;">
					<tr>
						<%if(sessionUser.getUserInfo().getUserType() == EnumUtil.SYS_USER_TYPE.DEFAULT.value){%>
						<td style="padding-left:8px;width:85px;" valign="top">
							<a href="javascript:void(0);" style="background:url('<%=contextPath %>/images/mydesktop.png') 3px 2px no-repeat;" class="deskbtn" onclick="MDIOpen('<%=contextPath+sysconfig.getProjectView() %>')">
								办公桌面
							</a>
						</td>
						
						<td style="width:85px;" valign="top">
							<a href="javascript:void(0);" style="background:url('<%=contextPath %>/images/mydesktopset.png') 3px 2px no-repeat;" class="deskbtn" onclick="MDIOpen('<%=contextPath %>/erp/desktop/desktop_set.jsp')">
								桌面设置
							</a>
						</td>
						<td id="shortcuttd" style="width:85px;position:relative;" valign="top">
							<a href="javascript:void(0);" style="background:url('<%=contextPath %>/images/shortcut.png') 3px 2px no-repeat;" class="deskbtn" onclick="MDIOpen('<%=contextPath %>/erp/desktop/shortcut.jsp')">
								快捷菜单
							</a>
						</td>
						
						<%} %>
						<td valign="top">
				            <TABLE style="WIDTH: 100%; TABLE-LAYOUT: fixed;" cellSpacing="0" border="0" cellPadding="0">
				              <TR>
				                <TD style="WIDTH: 1px"></TD>
				                <TD id=tab_left class=pre><A class=hidden title=向前 
				                  onclick=onLefttab(); href="javascript:void(0);">向前</A></TD>
				                <TD><IFRAME frameSpacing=0 marginHeight=0 id="tabFrame"
				                  src="<%=request.getContextPath() %>/js/tabs/systabs.html" frameBorder="0" width="100%" height="27"
				                  allowTransparency name=tabs marginWidth=0 
				                  scrolling=no></IFRAME></TD>
				                <TD id=tab_right class=next><A class=hidden title=向后 
				                  onclick=onRighttab(); href="javascript:void(0);">向后</A></TD>
				              </TR>
					        </TABLE>
						</td>
						
						<td width="380" valign="top" align="right">
							<iframe src="<%=request.getContextPath() %>/projectTopMenu.jsp?mid=<%=ConstWords.getProjectCode() %>" id="topfrm"
								 frameborder="0" height="25" scrolling="no" allowTransparency="true" marginheight="0" width="100%">
							</iframe>
						</td>
					</tr>
				</table>
			</td>
			</tr>
			</table>
			<!-- 首页顶部结束 -->
		</td>
		</tr>
		<tr>
		<td>
		<!-- 首页中间开始 -->
		<table width="100%" cellpadding="0" cellspacing="0" border="0" height="100%">
			<tr>
				<td id="split_l" style="width:200px;">
					<div class="div_title">功能菜单</div>
					<div class="div_content_top">
						<iframe frameborder="0" allowTransparency="true" id="methodleftfrm" width="100%" height="100%" scrolling="no" marginheight="0"></iframe>
					</div>
					<div class="div_title">模块切换</div>
					<div class="div_content_bottom">
					
						<!-- 个人模块切换开始 -->
						<%
						if(userModuleMethods != null && userModuleMethods.size()>0){
						 %>
						<table cellspacing="0" cellpadding="5" align="center" border="0">
						<%
						String imgs="";
						String click="";
						String tit="";
						String style = "";
							int row =Integer.parseInt(SystemConfig.getParam("erp.show.projectchange")==null?"3":SystemConfig.getParam("erp.show.projectchange"));
							for(int i=0;i<userModuleMethods.size();i++){
								SysMethodInfo sysMethod =userModuleMethods.get(i);
								int counttd=0;
								if(i%row==0){
								%>
								<tr>
								<%}%>
								<td nowrap="nowrap" valign="middle" align="center" width="<%=(ConstWords.IndexLeftWidth-row*8)/row %>" height="40">
								<%
								if(mid.equals(sysMethod.getPrimaryKey())){
									click = "onclick=\"projectOpen('"+sysMethod.getPrimaryKey()+"',"+i+",'"+sysMethod.getMethodInfoName()+"');\"";
									imgs = FileTool.getRepFileName(sysMethod.getImageSrc(),"_");
									tit = "当前模块:"+sysMethod.getMethodInfoName();
									style = "border: 1px solid #89B4D3;";
									%>
									<img id="img<%=i%>" src="<%=request.getContextPath()+"/images/projectimg/"+imgs %>" onmouseover="changebg(this,'#F7B20C','#F3DDA7');" onmouseout="changebg(this,'#89B4D3','#fbfbfb');" <%=click %> title="<%=tit %>"  style="<%=style %>"/>
									<%
								}else{
									click = "onclick=\"projectOpen('"+sysMethod.getPrimaryKey()+"',"+i+",'"+sysMethod.getMethodInfoName()+"');\"";
									imgs = sysMethod.getImageSrc();
									tit = "切换到:"+sysMethod.getMethodInfoName();
									style = "border: 1px solid #cccccc;background-color: #fbfbfb;cursor: pointer;";
									%>
									<img id="img<%=i%>" src="<%=request.getContextPath()+"/images/projectimg/"+imgs %>" onmouseover="changebg(this,'#F7B20C','#F3DDA7');" onmouseout="changebg(this,'#cccccc','#fbfbfb');" <%=click %>  title="<%=tit %>"  style="<%=style %>"/>
									<%
								}
								%>
								</td>
								<%
								counttd++;
								if((i%row ==0&&counttd%row==0)||i==userModuleMethods.size()-1){
								%>
								</tr>
								<%}%>
							<%} %>
						</table>
						<%} %>
						<script type="text/javascript">
						function projectOpen(id,num,title){
							var count = <%=userModuleMethods.size()%>;
							for(var i=0;i<count;i++){
								if(i != num){
									//未选中
									var img = document.getElementById("img"+i);
									var imgSrc = img.src;
									if(imgSrc.substring(imgSrc.length-5,imgSrc.length-4) == "_"){
										img.src = imgSrc.substring(0,imgSrc.length-5) + imgSrc.substring(imgSrc.length-4,imgSrc.length);
										img.style.cssText = "border: 1px solid #cccccc;background-color: #fbfbfb;cursor: pointer;";
										var t = img.title.split(":");
										img.title = "切换到:"+t[1];
									}
								}else{
									//选中
									var img = document.getElementById("img"+i);
									var imgSrc = img.src;
									if(imgSrc.substring(imgSrc.length-5,imgSrc.length-4) != "_"){
										//不是重复点击
										img.src = imgSrc.substring(0,imgSrc.length-4) + "_" + imgSrc.substring(imgSrc.length-4,imgSrc.length);
										img.style.border = "1px solid #89B4D3";
										img.onmouseover = "changebg(this,'#F7B20C','#F3DDA7');"
										img.onmouseout = "changebg(this,'#89B4D3','#fbfbfb');"
										img.title = "当前模块:"+title;
										document.getElementById("methodleftfrm").src = "<%=request.getContextPath() %>/erp/index_left.jsp?mid="+id;
									}
								}
							}
						}
						
						function changebg(obj,borcolor,bgcolor){
							obj.style.border ="1px solid "+borcolor;
							obj.style.backgroundColor = bgcolor;
						}
						</script>
						<!-- 个人模块切换结束 -->
						
					</div>
				</td>
				<td>
			        <iframe height="100%" width="100%" 
			            marginHeight=0 frameBorder=0 
			            name="mainframe" id="mainframe" marginWidth=0 scrolling=no></iframe>
				</td>
			</tr>
		</table>
		<!-- 首页中间结束 -->
		</td>
		</tr>
		
		
		<tr>
		<td height="30" style="background:#054376;">
			<!-- 首页底部开始 -->	
			<table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0">
				<tr>
					<td style="padding-left:10px;">
						<font color="#ffffff">
						(c)2008-2014 Eazytec BAMS Version 1.0
						</font>
					</td>
					<td style="padding-left:15px;padding-right:15px;" valign="middle">
					
					</td>
										
					<td align="right">
	                	<span id="systime" style="color:#FFFFFF;vertical-align: middle;"></span>
	                </td>					
					
					<td align="right" style="padding-right:5px;" width="140" valign="middle">
						<%@include file="index_bottom.jsp"%> 
					</td>
				</tr>
			</table>					
			<!-- 首页底部结束 -->	
		</td>
		</tr>
		</table>
		
	<%@include file="desktop/serverTimer.jsp"%>
	</body>
</html>
